﻿using System;

namespace block_explorer.NoiseSystem.Nodes
{
    class Ridge : INode
    {
        INode mSource;
        INode mOffset;

        public Ridge(INode source, INode offset)
        {
            mSource = source;
            mOffset = offset;
        }

        public Ridge(INode source, double offset)
        {
            mSource = source;
            mOffset = new Constant(offset);
        }

        public double Value(double x, double y, double z)
        {
            double h = mSource.Value(x, y, z);
            h = Math.Abs(h);
            h = mOffset.Value(x, y, z) - h;
            h = h * h;
            return h;
        }
    }
}
